package com.lc.sell.controller;


import com.lc.sell.mapper.OrderDetailMapper;
import com.lc.sell.service.OrderDetailService;
import com.lc.sell.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙晨
 * @since 2022-02-12 12:28:21
 */
@RestController
@RequestMapping("orderDetail")
public class OrderDetailController {

    @Autowired
    private OrderDetailService orderDetailService;

    @GetMapping("orderDetails")
    public ModelAndView toOrderDetail(@RequestParam(value = "orderId") String orderId){
        ModelAndView mv = new ModelAndView();
        mv.addObject("oid",orderId);
        mv.setViewName("page/orderDetails");
        return mv;
    }

    @GetMapping("info")
    public ResultVo DetailInfo(@RequestParam(value = "orderId") String orderId, HttpServletRequest request){
        Integer mid = (Integer) request.getSession().getAttribute("mid");
        System.out.println(mid);
        return ResultVo.ok(200,"成功",orderDetailService.findByIdDetail(orderId,mid));
    }
}
